package com.cy.pj.goods.controller;


import com.cy.pj.goods.pojo.Goods;
import com.cy.pj.goods.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/goods/")//定义url中的共性部分
public class CoodsController {

    @Autowired
    private GoodsService goodsService;
//http://localhost/doFindGoods
@GetMapping("doFindGoods")
    public String doFindGoods(Model model){
    List<Goods> list=goodsService.findGoods();
    for(Goods g:list){
        System.out.println(g);
    }
    model.addAttribute("list",list);
    return "goods";
}
}
